package com.richard.dev.common.application;

import androidx.multidex.MultiDexApplication;

import com.alibaba.android.arouter.launcher.ARouter;
import com.richard.dev.common.BuildConfig;
import com.richard.library.basic.util.LogUtil;
import com.richard.library.context.AppContext;

/**
 * author Richard
 * date 2019-06-04 11:03
 * version V1.0
 * description: App
 * \u0020为半角空格，\u3000为全角空格
 */
public class App extends MultiDexApplication {

    private static App instance;

    public static App getInstance() {
        return instance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        this.init();
    }


    /**
     * 初始化
     */
    private void init() {
        CommonInit
                .open()
                .setDebug(BuildConfig.DEBUG)
                .setEnabledCrashHandler(true)
                .setEnabledX5TBS(false)
                .setLogTag("api")
                .setOpenCrossProcessEventBusReceiver(true)
                .build(this);

        //初始化日志工具类
        LogUtil.getConfig()
                .setGlobalTag("api")
                .setDir(AppContext.get().getFilesDir() + "/logs")
                .setLogFileHoldDays(1)
                .setIs2FilePrintConsole(AppContext.isDebug())
                .setFilePrefix("Log")
                .setLogHeadSwitch(false)
                .setBorderSwitch(false)
                .setLogSwitch(true);

        ARouter.init(this);
        ARouter.openLog();
        ARouter.openDebug();
    }
}
